package com.nxy.cpfsfe.util;

import com.adtec.starring.exception.BaseException;
import com.adtec.starring.global.SysDef;
import com.adtec.starring.respool.SystemParameter;
import com.adtec.starring.util.SpringUtil;
import com.nxy.cpfsfe.PubBeanSerial;
import com.nxy.cpfsfe.enumtype.MsgCdOrTpEnum;
import com.nxy.cpfsfe.enumtype.RespCd;
import com.nxy.cpfsfe.enumtype.TcSequenceEnum;
import com.nxy.cpfsfe.mybatis.mapper.ToOrgMapper;
import com.nxy.cpfsfe.mybatis.pojo.ToOrg;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.dom4j.DocumentException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;


public class XmlCPFSBuildUtil {
	private final static Logger LOGGER = LoggerFactory.getLogger(XmlCPFSBuildUtil.class);

	/**
	 * 创建CPFS回执报文头
	 * @param xmlReqDoc
	 * @param code
	 * @param map
	 */
	public static void buildXmlResponseHead(XMLNodeUtil xmlReqDoc, String code, Map<String, String> map) {
		String date = DateUtil.getDate();
		String time = DateUtil.getTime();
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/sndDt",date);  //报文发起日期       说明：是否必填M 长度：8
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/MsgTp", code);  //报文编号
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/CorrId", StringUtil.trimObject(map.get("/root/MsgHeader/CorrId")));//通讯流水号
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/TrxId", StringUtil.trimObject(map.get("/root/MsgHeader/TrxId")));//交易流水
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/OriTrxId",  StringUtil.trimObject(map.get("/root/MsgHeader/OriTrxId")));//原业务流水号
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/AcctChannel",   StringUtil.trimObject(map.get("/root/MsgHeader/AcctChannel")));
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/SysRetCode",  StringUtil.trimObject(map.get("resultCode")));
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/SysRetMsg",   StringUtil.trimObject(map.get("msg")));
		xmlReqDoc.setNodeContentTrim("/root/MsgHeader/AcctDate", date);
	}
}
